package com.wang.controller;

import com.wang.config.DubboServiceBuilder;
import com.wang.dto.DemoVo;
import com.wang.service.IDemoService;
import org.apache.dubbo.config.annotation.Reference;
import org.apache.dubbo.rpc.RpcContext;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@RestController
public class DemoController {

    @Reference(interfaceClass = IDemoService.class,version = "1.0.0",group = "dev",timeout = 1500/*,registry = {"registryConfigLocal"},loadbalance = "consistenthash",timeout = 1000,cluster = "failfast",mock = "fail:com.wang.service.IDemoServiceMock"*/)
    private IDemoService demoService;


    @GetMapping("/getDemo")
    public String getDemo(String param) throws Exception {
        DemoVo demoVo = new DemoVo();
        demoVo.setId(12);
        demoVo.setName("wang");
        String s = demoService.testS(demoVo);
        System.out.println(s);
        String msg = demoService.getMsg(param);
        //System.out.println("msg = " + msg);
        //Future<String> future = RpcContext.getContext().getFuture();
        //return future.get();
        String company = RpcContext.getContext().getAttachment("company");
        return msg;
    }
}
